package hv.fmw.mvc.view {
	import hv.fmw.mvc.model.ModelEvent;

	import flash.display.Sprite;
	import flash.events.Event;
	/**
	 * @author hvong
	 */
	public class AbstractView extends Sprite {
		
		public function AbstractView() {
			addEventListener(Event.ADDED_TO_STAGE, _onAddedToStageHandler);
			addEventListener(ModelEvent.MODEL_READY, build);
			addEventListener(ModelEvent.MODEL_UPDATE, update);
		}

		protected function update(event : ModelEvent) : void {
		}

		protected function build(event:ModelEvent) : void {
			removeEventListener(ModelEvent.MODEL_READY, build);
		}

		private function _onAddedToStageHandler(event : Event) : void {
			removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStageHandler);
			ViewManager.getInstance().addView(this);
			if(this is IResizable) IResizable(this).resize();
		}
	}
}
